using IGeekFan.AspNetCore.Knife4jUI;
using MesProjectERP.Host;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddControllers().AddJsonOptions(a => a.JsonSerializerOptions.PropertyNamingPolicy = null);
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(a =>
{
    var file = Path.Combine(AppContext.BaseDirectory + "MesProjectERP.Host.xml");
    a.IncludeXmlComments(file, true);
});


builder.Services.AddAutoMapper(typeof(AutoMapperFiles));
builder.Services.AddDbContext<MesProjectERPContext>(a =>
{
    a.UseMySql(builder.Configuration.GetConnectionString("MySql"), new MySqlServerVersion("5.7"));
});
var app = builder.Build();
app.UseCors(a => a.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());

// Configure the HTTP request pipeline.
//if (app.Environment.IsDevelopment())
//{

//}
app.UseSwagger();
//    app.UseSwaggerUI();
app.UseKnife4UI();


app.UseAuthorization();

app.MapControllers();

app.Run();
